package model;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Patient 
{
	private String patientID;
    private String name;
    private String race;
    private String gender;
    private String insurer;
    private String dob;
    private String bloodType;
    private String religion;
    private String country;
    private String state;
    private String city;
    private String postalCode;
    private String address;

    
    //Patient Constructor to initialize all necessary patient data to display, such as the following:
    // patientID, firstName, lastName, middleInitial, race, gender, insurer, dob, bloodType, religion, country, state,
    // city, postalCode, address
    public Patient(String patientID, String firstName, String lastName, String middleInitial, String race, String gender, 
    		String insurer, String dob, String bloodType, String religion, String country, String state, String city, 
    		String postalCode, String address)
    {
        this.patientID = patientID;
        this.name = lastName+ ", " + firstName + " "+  middleInitial + ".";
        this.race = race;
        this.gender = gender;
        this.insurer = insurer;
        this.bloodType = bloodType;
        this.religion = religion;
        this.country = country;
        this.state = state;
        this.city = city;
        this.postalCode = postalCode;
        this.address = address;
        
        //Block to catch potential errors caused by parsing and formatting the date of birth string
        try 
        {
        	//Creates a Date format to parse a string into a Data
        	DateFormat inputFmt = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.S");
        	Date date = inputFmt.parse(dob);

        	//Creates a Date format to format the date into the desired MM-DD-YYYY string structure
        	DateFormat outputFmt = new SimpleDateFormat("MM-dd-yyyy");
        	dob = outputFmt.format(date);
		} catch (ParseException e) 
		{
			e.printStackTrace();
		}
        this.dob = dob;  
    }
      
    
    //Shorter Patient Constructor to initialize all necessary patient data to display in JQuery DataTable, such as the following:
    // firstName, lastName, middleInitial, address, city, state, postalCode, country, patientID
    public Patient(String firstName, String middleInitial, String lastName, String gender, 
    		String bloodType, String dob, String address, String city, String state, String postalCode, String patientID, String country)
    {
    	this.patientID = patientID;
        this.name = lastName+ ", " + firstName + " "+  middleInitial + ".";
        this.gender = gender;
        this.bloodType = bloodType;
        this.address = address;
    	this.city = city;
    	this.state = state;
    	this.postalCode = postalCode;
    	this.country = country;
        
    	//Block to catch potential errors caused by parsing and formatting the date of birth string
        try 
        {
        	//Creates a Date format to parse a string into a Data
        	DateFormat inputFmt = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.S");
        	Date date = inputFmt.parse(dob);

        	//Creates a Date format to format the date into the desired MM-DD-YYYY string structure
        	DateFormat outputFmt = new SimpleDateFormat("MM-dd-yyyy");
        	dob = outputFmt.format(date);
		} catch (ParseException e) 
		{
			e.printStackTrace();
		}
        this.dob = dob;
    	
    }

    
    //**************************Getter And Setters for Patient data****************************************//
	public String getPatientID() 
	{
		return patientID;
	}
	public void setPatientID(String patientID) 
	{
		this.patientID = patientID;
	}
	
	
	public String getName() 
	{
		return name;
	}
	public void setName(String firstName, String middleInitial, String lastName) 
	{
		this.name = lastName+ ", " + firstName + " "+  middleInitial + ".";
	}
	
	
	public String getRace() 
	{
		return race;
	}
	public void setRace(String race) 
	{
		this.race = race;
	}
	
	
	public String getGender() 
	{
		return gender;
	}
	public void setGender(String gender) 
	{
		this.gender = gender;
	}
	
	
	public String getInsurer() 
	{
		return insurer;
	}
	public void setInsurer(String insurer) 
	{
		this.insurer = insurer;
	}
	
	
	public String getDOB() 
	{
		return dob;
	}
	public void setDOB(String dob) 
	{
		this.dob = dob;
	}
	
	
	public String getBloodType() 
	{
		return bloodType;
	}
	public void setBloodType(String bloodType) 
	{
		this.bloodType = bloodType;
	}
	
	
	public String getReligion() 
	{
		return religion;
	}
	public void setReligion(String religion) 
	{
		this.religion = religion;
	}
	
	
	public String getCountry() 
	{
		return country;
	}
	public void setCountry(String country) 
	{
		this.country = country;
	}
	
	
	public String getState() 
	{
		return state;
	}
	public void setState(String state) 
	{
		this.state = state;
	}
	
	
	public String getCity() 
	{
		return city;
	}
	public void setCity(String city) 
	{
		this.city = city;
	}
	
	
	public String getPostalCode() 
	{
		return postalCode;
	}
	public void setPostalCode(String postalCode) 
	{
		this.postalCode = postalCode;
	}
	
	
	public String getAddress() 
	{
		return address;
	}
	public void setAddress(String address) 
	{
		this.address = address;
	}

}
